﻿// Decompiled with JetBrains decompiler
// Type: MCM.Abstractions.MemorySettingsFormat
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using MCM.Abstractions.Base;
using MCM.Abstractions.GameFeatures;
using System.Collections.Generic;

#nullable enable
namespace MCM.Abstractions
{
  public sealed class MemorySettingsFormat : ISettingsFormat
  {
    private readonly Dictionary<string, BaseSettings> _settings = new Dictionary<string, BaseSettings>();

    public IEnumerable<string> FormatTypes { get; } = (IEnumerable<string>) new string[1]
    {
      "memory"
    };

    public BaseSettings Load(BaseSettings settings, GameDirectory directory, string filename)
    {
      BaseSettings overrideSettings;
      if (this._settings.TryGetValue(directory.Path + filename, out overrideSettings) || settings != overrideSettings)
        SettingsUtils.OverrideSettings(settings, overrideSettings);
      return settings;
    }

    public bool Save(BaseSettings settings, GameDirectory directory, string filename)
    {
      this._settings[directory.Path + filename] = settings;
      return true;
    }
  }
}
